package edu.sctu.zhengsenwen.month201505.day20150529;


import java.util.HashMap;
import java.util.Scanner;

/**
* Created by user15 on 2015/5/29.
*/
public class HasMap {

    Scanner input = new Scanner(System.in);

    HashMap<String, Student> map = new HashMap<String,Student>();

    public void setHAshMap() {

        for ( int check = 1 ; check == 1; check = input.nextInt()) {
            Student student = new Student();

            System.out.println("请输入你的名字：");
            student.name = input.next();

            System.out.println("请输入你的年龄：");
            student.age = input.nextInt();

            map.put(student.name,student);

            System.out.println("\n输入 1 继续添加数据，输入其它结束添加: ");
        }

    }

    public void printHashMap(){

        System.out.println("下面是输出信息：");

        System.out.println(map.keySet());

        String studentName = input.next();

        System.out.println("该生姓名： " +  map.get(studentName).name
         + "    该生年龄： " + map.get(studentName).age);

    }



        }
